﻿#ifndef __RM_H__
#define __RM_H__
//#include "Global.h"
#include "Texture.h"
#include "Surface.h"
#include "Map.h"
#include "Sprite.h"
#include <vector>
using namespace std;


/**--------------------------------------------------------
*Program/Project : GameMario
*Written by : 
*Email :
*Created date : 7/10/2012
*Modified by :
*Modified date :
*Version : 1.0
*Description : Load va quan ly tai nguyen nhu am thanh, hinh anh,..
--------------------------------------------------------**/
enum ResourceID
{
	RESOURCE__GAMEPLAY_MAP,
	RESOURCE_MARIO,
};
enum INFO_SCREEN
{
	INFO_MARIO,
	INFO_COIN,
	INFO_WORLD1,
	INFO_WORLD2,
	INFO_TIME,
	INFO_RESULT
};
enum SCORE_LIST
{
	SCORE,
	COIN,
	NUMBER_LIFE,
	TIME,
	WORLD1,
	WORLD2
};



enum ITEM_STATE
{
	IS_REMOVE,		//trang thai can xoa
	IS_IDLE,		//trang thai binh thuong
	IS_MOVING,		//item co the di chuyen
	IS_ACTIVING,	//kich hoat item hien len
	//IS_ATE,			//item bi mario an
	IS_FREE,		//trang thai tu do
	IS_READY,		//trang thai san sang
	IS_FLOWER,		//trang thai la hoa, khong phai nam
	IS_EXPLOSION	//trang thai no cua bullet
};

enum BLOCK_STATE
{
	BS_REMOVE,		//khi gach bi vo, can xoa
	BS_NORMAL,		//trang thai binh thuong
	BS_IDLE_2,
	BS_MOVEUP,		//gach bi nhay len 1 doan khi mario doi len
	BS_BREAKING,	//gach dang bi vo
	BS_BREAKED,		//gach da vo
	BS_ACTIVING,		//cho phep object hoat dong
	BS_NONE			//gach:21 chua 5 coin
};

enum ENEMY_STATE
{
	ES_REMOVE,
	ES_NORMAL,
	ES_ACTIVING,
	ES_STOP,				//Khi Goomba hoặc Koopa bị dậm
	ES_MOVE_SHELL_LEFT,		//Khi Koopa di chuyển trong mai rùa.
	ES_MOVE_SHELL_RIGHT,
	ES_FALL,				//Khi Goomba hoặc Koopa bị rơi (chuẩn bị chết)
	ES_FALLBULLET,			//Khi Koopa bi bullet mario cham
	ES_DIED
};

enum MARIO_STATE
{
	MS_REMOVE,			//xoa mario
	MS_DIE,				//mario dang chet
	MS_NORMAL,			//binh thuong
	MS_SMALLTOBIG,		//trang thai chuyen tu nho den lon
	MS_BIGTOSMALL,		//trang thai chuyen tu lon den nho
	MS_BIGTOBULLET,		//trang thai chuyen tu lon den bullet
	MS_BULLETTOSMALL,	//trang thai chuyen tu bullet den nho
	MS_PROTECT,			//trang thai bao ve mario sau khi chet
	MS_HASSTAR,			//trang thai mario da an sao
	MS_CREPTPINE,		//mario chui vao cong(Pine)
	MS_GOUPPINE,		//mario chui len cong(Pine)
	MS_INTOPINE			//mario chui vao cong(Pine)
};


enum GAME_STATE
{
	GS_MENU,			//menu chinh
	GS_PLAYING,			//dang choi
	GS_LOAD,			//load man choi
	GS_SAVE,			//luu man choi
	GS_GAMEWIN,			//man hinh win
	GS_GAMEOVER,		//man hinh thua
	GS_NEXT_STAGE,		//man choi ke tiep
	GS_SUB_STAGE,		//man choi phu trong map chinh
	GS_REPLAY,			//choi lai man choi
	GS_RETURN_STAGE,	//tro lai man choi
	GS_ABOUT,			//thong tin ve game
	GS_CONFIRM			//thong bao xac nhan 1 hanh dong
};


class ResourceMng
{
private:
	LPDIRECT3DDEVICE9 d3ddv;
	LPDIRECT3DSURFACE9 backBuffer;

	//load all resource
	ResourceMng(LPDIRECT3DDEVICE9 D3ddv, LPDIRECT3DSURFACE9 BackBuffer);

	//unique instance, dam bao chi co 1 thuc the duy nhat nam giu cac tai nguyen
	static ResourceMng* _instance;

	//-------------------- RESOURCE ----------------------
	//List of surface
	vector<SURFACE*> _listSurface;
	vector<Object*> maplist;
	Map *map;
	//List of Texture2
	vector<Texture*>_listTexture;

public:
	//release all resource
	~ResourceMng(void);

	//get the unique instance, lay thuc the giu cac tai nguyen
	static ResourceMng* GetInst(LPDIRECT3DDEVICE9 D3ddv, LPDIRECT3DSURFACE9 BackBuffer);
	Sprite *GetSprite(ResourceID id);
	//get surface, texture
	SURFACE* GetSurface(LPWSTR fileName);
	Texture* GetTexture(LPWSTR fileName);
	Map *GetMap(ResourceID id);
	
};

#endif